#include "stdafx.h"
#include "t_MessageRecipientPing.h"

t_MessageQueue p_MessageQueue;
t_MessageRecipientPing p_Ping;
t_MessageRecipientPing p_Ping2;

static void t_MessageTest()
{
	t_Message msg1(NULL, 1, clock());
	t_Message msg2(NULL, 1, clock() + 1);
	// Testing operator < 
	assert(msg1 < msg2);
	assert((msg2 < msg1) == false);
}

int _tmain(int argc, _TCHAR* argv[])
{
	// new t_MessageQueue;
	clock_t tm = clock();
	t_MessageTest();
	p_MessageQueue.SendMessage(&p_Ping, 0, 1, 0);
	p_MessageQueue.SendMessage(&p_Ping2, 0, 2, 0);
	while (clock() < (tm + 3*CLOCKS_PER_SEC))
	{
		p_MessageQueue.Poll();
	}

	p_MessageQueue.StartThread();

	while (clock() < (tm + 6*CLOCKS_PER_SEC))
	{
		SleepEx(50,0);
	}

	return 0;
}
